<template>
    <Card :bordered="false" dis-hover style="margin-bottom: 56px;">
        <Tabs v-model="currentTab" name="a" :animated="false" @on-click="clicktab">
            <TabPane :label="`新增（${totallist.add || 0}）`" name="add" tab="a">
                <addpatient ref="addpatient" @alltotal="alltotal"></addpatient>
            </TabPane>
            <TabPane :label="`预到（${totallist.order_arrive || 0}）`" name="preArrival" tab="a">
                <preArrivalpatient  ref="preArrivalpatient" @alltotal="alltotal"></preArrivalpatient>
            </TabPane>
            <TabPane :label="`已到（${totallist.arrive || 0}）`" name="arrived" tab="a">
                <arrivedpatient  ref="arrivedpatient" @alltotal="alltotal"></arrivedpatient>
            </TabPane>
            <TabPane :label="`过期未到（${totallist.unarrive || 0}）`" name="overdue" tab="a">
                <overduepatient  ref="overduepatient" @alltotal="alltotal"></overduepatient>
            </TabPane>
            <TabPane :label="`预约（${totallist.oprate_arrive || 0}）`" name="ordered" tab="a">
                <orderedpatient  ref="orderedpatient" @alltotal="alltotal"></orderedpatient>
            </TabPane>
            <TabPane :label="`改约（${totallist.change_arrive || 0}）`" name="revision" tab="a">
                <revisionpatient  ref="revisionpatient" @alltotal="alltotal"></revisionpatient>
            </TabPane>
        </Tabs>
    </Card>
</template>
<script>
    import { patientindextabtotal } from '@/api/hqapi';
    import addpatient from './addpatient';
    import preArrivalpatient from './preArrivalpatient';
    import arrivedpatient from './arrivedpatient';
    import overduepatient from './overduepatient';
    import orderedpatient from './orderedpatient';
    import revisionpatient from './revisionpatient';
    export default {
        name: 'patient',
        components: { addpatient, preArrivalpatient, arrivedpatient, overduepatient, orderedpatient, revisionpatient },
        data() {
            return {
                currentTab: 'add',
                totallist: { add: '', order_arrive: '', arrive: '', unarrive: '', oprate_arrive: '', change_arrive: '' }
            };
        },
        mounted() {
            this.initial();
        },
        methods: {
            clicktab(e) {
                switch(e) {
                    case 'add':
                        this.$refs.addpatient.initial(e);
                        break;
                    case 'preArrival':
                        this.$refs.preArrivalpatient.initial(e);
                        break;
                    case 'arrived':
                        this.$refs.arrivedpatient.initial(e);
                        break;
                    case 'overdue':
                        this.$refs.overduepatient.initial(e);
                        break;
                    case 'ordered':
                        this.$refs.orderedpatient.initial(e);
                        break;
                    case 'revision':
                        this.$refs.revisionpatient.initial(e);
                        break;
                }
            },
            initial() {
                this.clicktab('add');
                patientindextabtotal({ type: 0 }).then(res => {
                    this.$refs.addpatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.$refs.preArrivalpatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.$refs.arrivedpatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.$refs.overduepatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.$refs.orderedpatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.$refs.revisionpatient.condition(JSON.parse(JSON.stringify(res.condition)));
                    this.totallist.add = res.tab_totals.add;
                    this.totallist.order_arrive = res.tab_totals.order_arrive;
                    this.totallist.arrive = res.tab_totals.arrive;
                    this.totallist.unarrive = res.tab_totals.unarrive;
                    this.totallist.oprate_arrive = res.tab_totals.oprate_arrive;
                    this.totallist.change_arrive = res.tab_totals.change_arrive;
                });
            },
            alltotal(e) {
                if(e.key === 'add') this.totallist.add = e.total;
                else if(e.key === 'order_arrive') this.totallist.order_arrive = e.total;
                else if(e.key === 'arrive') this.totallist.arrive = e.total;
                else if(e.key === 'unarrive') this.totallist.unarrive = e.total;
                else if(e.key === 'oprate_arrive') this.totallist.oprate_arrive = e.total;
                else if(e.key === 'change_arrive') this.totallist.change_arrive = e.total;
            }
        }
    };
</script>
